<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
	<th:block th:include="include :: header('新增婚庆公司')" />
</head>
<body class="white-bg">
	<div class="wrapper wrapper-content animated fadeInRight ibox-content">
		<form class="form-horizontal m" id="form-company-add">
			<div class="form-group">
				<label class="col-sm-3 control-label">公司名称：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyName" id="companyName" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">法人姓名：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyBoss" id="companyBoss" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">密码：</label>
				<div class="col-sm-8">
					<input id="password" name="password" class="form-control" type="password">
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">确认密码：</label>
				<div class="col-sm-8">
					<input id="confirmPassword" name="confirmPassword" class="form-control" type="password">
					<span class="help-block m-b-none"><i class="fa fa-info-circle"></i> 请再次输入您的密码</span>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label ">手机号：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyPhone" id="companyPhone" required>
				</div>
			</div>
			<div class="form-group">
				<label class="col-sm-3 control-label">邮箱：</label>
				<div class="col-sm-8">
					<input class="form-control" type="text" name="companyEmail" id="companyEmail" required>
				</div>
			</div>
		</form>
	</div>
	<th:block th:include="include :: footer" />
	<script type="text/javascript">



		var prefix = ctx + "user/company";
		var icon = "<i class='fa fa-times-circle'></i> ";
		$("#form-company-add").validate({
			onkeyup: false,
			rules:{
				password: {
					required: true,
					minlength: 5
				},
				confirmPassword: {
					required: true,
					minlength: 5,
					equalTo: "#password"
				},
				companyPhone:{
					remote: {
		                url: prefix +"/checkPhone",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"hostPhone" : function() {
		                        return $.common.trim($("#companyPhone").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},

				companyEmail:{
					remote: {
		                url: prefix +"/checkEmail",
		                type: "post",
		                dataType: "json",
		                data: {
		                	"hostEmail" : function() {
		                        return $.common.trim($("#companyEmail").val());
		                    }
		                },
		                dataFilter: function(data, type) {
		                	return $.validate.unique(data);
		                }
		            }
				},
			},
			messages: {
				password: {
					required: icon + "请输入您的密码",
					minlength: icon + "密码必须5个字符以上"
				},
				confirmPassword: {
					required: icon + "请再次输入密码",
					minlength: icon + "密码必须5个字符以上",
					equalTo: icon + "两次输入的密码不一致"
				},
		        "companyPhone": {
		            remote: "手机号已经存在"
		        },
		        "companyEmail": {
		            remote: "邮箱已经存在"
		        }
		    },
		    focusCleanup: true
		});
		
		function submitHandler() {
	        if ($.validate.form()) {
	        	$.operate.save(prefix + "/add", $('#form-company-add').serialize());
	        }
	    }

	</script>
</body>
</html>
